<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<script  runat="server">
Dim TotalRecords=0,TotalPages=0,CurrentPage=0
Dim rows=5,strShow As String="",ID="",Name=""
Dim querystring="",subquerystring=""
Sub Page_Load(ByVal sender As Object, _
	ByVal e As EventArgs)
	CurrentPage=DataResult.CurrentPageIndex+1
	If Not Page.IsPostBack Then			
		BindGrid()
        	End If
	TotalPages=DataResult.PageCount	
End Sub
Sub MyDataGridPage(sender As Object, e As _
	DataGridPageChangedEventArgs) 
	DataResult.CurrentPageIndex = e.NewPageIndex		
	BindGrid	
End Sub
Private Sub BindGrid()
	Dim strSQL="select * from vwNewItems " 
	strSQL += " order by CustomerRating ASC, ItemName ASC" 
	
	
	rows=request.QueryString("rows")
	if rows="" or not isnumeric(rows) then rows=5
	Dim pages=request.QueryString("pages")
	if pages="" or not isnumeric(pages) then pages=5

	querystring="alphabet.aspx?id=" + ID + "&name=" + Name	
	subquerystring="&from_=alphabet.aspx"
	subquerystring += "&rows=" & rows
	subquerystring += "&pages=" & pages	
	subquerystring += "&pg=" & CurrentPage.toString()

	DataResult.PageSize=rows	
	DataResult.PagerStyle.PageButtonCount=pages
	 	
	Dim myConnection As SqlConnection = _
	New SqlConnection(ConfigurationSettings.appSettings("conn"))	
	dim myAdapter as SqlDataAdapter = _
	New SqlDataAdapter(strSQL, myConnection)
	dim myDataSet as DataSet = New DataSet()		
	myAdapter.Fill(myDataSet,strSQL)
	TotalRecords=myDataSet.Tables(strSQL).Rows().Count
	if TotalRecords >rows  then
		DataResult.AllowPaging="True"
	else
		DataResult.AllowPaging="False"
	end if		
	DataResult.DataSource=myDataSet
	DataResult.DataBind()
End Sub
</script>
<HTML><HEAD><TITLE>InterShop-Online Shopping</TITLE>
<META http-equiv=Content-Type content="text/html; charset=UTF-8">
<META content=""  name=description>
<META content="trading software platform" name=keywords>
<META http-equiv=Pragma content=no-cache>
<LINK href="style.css" type=text/css rel=stylesheet>
<SCRIPT language=JavaScript>
        	self.defaultStatus = "Online-Shopping!";                           
</SCRIPT>
</HEAD>
<BODY bottomMargin=0 leftMargin=0 topMargin=0  rightMargin=0 marginheight="0"  marginwidth="0">
<!--#include file="top.aspx"-->
<TABLE cellSpacing=0 cellPadding=0 border=0  width="775" >
  <TBODY> 
  <TR>
    <TD vAlign=top height="843" width="160"> 
      <table width="18%" border="0" cellspacing="0" cellpadding="0" align="center">
        <tr> 
          <td align="center"><br>
            <table border=0 cellspacing=0 cellpadding=0>
              <tr valign=bottom align=center> 
                <td><img src="images/web-search.gif" height="19" width="155"></td>
              </tr>
              <tr valign=top align=center> 
                <td> 
                  <table border=0 width=155 cellpadding=1 cellspacing=0 bgcolor=#708090 >
                    <tr> 
                      <td width=100% > 
                        <table width=100% border=0 cellpadding=4 cellspacing=0 bgcolor=#FFFFFF>
                          <tr> 
                            <td valign=top width=8% align="left" bgcolor="#CAE2F0"> 
                              <input size=15  onFocus="this.value = '';" value="Keyword" name=txtKeyword2 class=textbox>
                              <img height=21 
            alt="Click here to search the Item." 
            src="images/go-button.gif" 
            width=21 align=absMiddle 
      border=0> <br>
                              <img src="images/powered-by-google.gif" width="95" height="14"> 
                            </td>
                          </tr>
                        </table>
                      </td>
                    </tr>
                  </table>
            </table>
      </table>
      <table width="18%" border="0" cellspacing="0" cellpadding="0" align="center">
        <tr> 
          <td align="center"><br>
            <table border=0 cellspacing=0 cellpadding=0>
              <tr valign=bottom align=center> 
                <td><img src="images/browse-items.gif" width="155" height="19"></td>
              </tr>
              <tr valign=top align=center> 
                <td> 
                  <table border=0 width=155 cellpadding=1 cellspacing=0 bgcolor=#708090 >
                    <tr> 
                      <td width=100% height="49"> 
                        <table width=100% border=0 cellpadding=4 cellspacing=0 bgcolor=#FFFFFF>
                          <tr> 
                            <td valign=top width=8% align="left" height="51" bgcolor="#CAE2F0"> 
                              <!--#include file="includes/listsubcategories.htm"-->
                            </td>
                          </tr>
                        </table>
                      </td>
                    </tr>
                  </table>
            </table>
      </table>
      <!--#include file="left.aspx"-->
    </TD>
    <TD class=margin width="1" valign="top" align="right" bgcolor="#666666" height="843" > 
    </TD>
    <TD class=text_normal id=mainContent vAlign=top width="425"> 
      <TABLE cellSpacing=4 cellPadding=4 width="100%" align=left border=0 height="61">
        <TR> 
          <TD vAlign=top align=left> 
            <!--#include file="submenu.aspx"-->
            <br><img src="images/newprod.gif"><br><br>
	
          </TD>
        </TR>
        <TBODY> 
        <TR> 
          <TD vAlign=top align=middle height="207"> 
	<form runat=server>
                   <table width="100%" border="0" 
		cellpadding="0" cellspacing="0">
                      <tr> 
                        <td >          
                          <asp:DataGrid  
		ID="DataResult"	
		ClientID="dgGrid"	
		AllowSorting="True"
		PagerStyle-Mode="NumericPages"
		PagerStyle-Position ="TopAndBottom"			
		PagerStyle-HorizontalAlign="Right"
		OnPageIndexChanged="MyDataGridPage" 
		BorderColor="black"
		BorderWidth="0"
		GridLines="Both"
		CellPadding="4"
		CellSpacing="0"
		Font-Name="Verdana"
		Font-Size="8pt"
		Width="100%" 	
		HeaderStyle-CssClass="row_top"
		Headerstyle-BackColor="gray"
		Headerstyle-Font-Name="Arial"
		Headerstyle-Font-Size="10"
	        	Headerstyle-Font-Bold="True" 
		AlternatingItemStyle-BackColor="#e5f4ff"
		AlternatingItemStyle-ForeColor="blue"
		AlternatingItemStyle-Font-Name="Arial"
		ShowHeader="False"
		AutoGenerateColumns="False" runat="server" > 
		<Columns> 
                          	<asp:TemplateColumn HeaderText="Image"> 
		<ItemTemplate> 
		<asp:Label ID="Image" Text=<%# 
		"<img src='books/" & _
		 DataBinder.Eval(Container.DataItem,  _
		"ImagePathSmall").toString() & _
		 "' height=100 width=80>" %> Runat=server /> 
                          	</ItemTemplate> </asp:TemplateColumn>
		                          	
		<asp:TemplateColumn HeaderText="CateName"> 
		<ItemTemplate> 
                          	<asp:Label ID="ItemName" Text=<%# 
		"<br><a href=""details.aspx?itemid=" & _
		DataBinder.Eval(Container.DataItem, "ItemID").toString() & _
		"&aid=" + DataBinder.Eval(Container.DataItem, "AuthID").toString()  & _
		"&scid=" + DataBinder.Eval(Container.DataItem, "SubCateID").toString()  & _	
		"&sid=" + subquerystring  & _		
		""">" & _
		 DataBinder.Eval(Container.DataItem, "ItemName") & _
		 "</a> <br>" & _
		 DataBinder.Eval(Container.DataItem, "AuthorName").toString() & _
		"<br>Đánh giá của khách hàng: " & _
		"<img src='icons/stars" & _
		DataBinder.Eval(Container.DataItem, "CustomerRating").toString() & _
		 ".gif'><br> Nhà xuất bản: " & _
		DataBinder.Eval(Container.DataItem, "ProName").toString() & _
		"<br>Giá bìa: "  & _
		 DataBinder.Eval(Container.DataItem, "ListPrice").toString() & _
		"<br>Giảm giá: "  & _
		 DataBinder.Eval(Container.DataItem, "SalesDiscount").toString() & _
		"<Br>Giá bán: "  & _
		 DataBinder.Eval(Container.DataItem, "SalesPrice").toString() & _
		"<br>Kiểu bìa: "  & _
		 DataBinder.Eval(Container.DataItem, "ItemStyle").toString() & _
		"<br>"  + DataBinder.Eval(Container.DataItem, "Available").toString() %> 
		Runat=server /> 
                          	</ItemTemplate> </asp:TemplateColumn>
		</Columns> </asp:DataGrid> 
                        </td>
                      </tr>
	        <tr>                      
                        <td class="black-sm" width="50%" align="left">
		<hr>
		Results: <font color=red><%=TotalRecords%>
		</font>  Items | <font color=red><%=CurrentPage%>
		</font> - <%=TotalPages%> displayed.</td>                       
                      </tr>
                </table>
	</form>
          </TD>
        </TR>
        </TBODY> 
      </TABLE>
    </TD>
    <TD class=margin width="1" valign="top" align="right" bgcolor="#666666" height="843"> 
    </TD>
    <TD class=margin valign="top" align="center" height="843" width="160"> 
      <TABLE>
       
	<tr><td>&nbsp;</td><td valign=top>
	  <!--#include file="includes/right-next.htm" --></td></tr>
	    <tr>
          <td>&nbsp;</td>
          <td><br>
            <table width="18%" border="0" cellspacing="0" cellpadding="0">
              <tr> 
                <td align="center"> 
                  <table border=0 cellspacing=0 cellpadding=0>
                    <tr valign=bottom align=center> 
                      <td><img src="images/top-products.gif" width="155" height="19"></td>
                    </tr>
                    <tr valign=top align=center> 
                      <td> 
                        <table border=0 width=155 cellpadding=1 cellspacing=0 bgcolor=#708090 >
                          <tr> 
                            <td width=100%> 
                              <table width=100% border=0 cellpadding=4 cellspacing=0 bgcolor=#FFFFFF>
                                <tr> 
                                  <td valign=top width=8% align="left" height="52"> 
                                    <p>&nbsp;</p>
                                  </td>
                                  <td valign=top width=92% align="left" height="52"> 
                                    <!--#include file="includes/right-top.htm" -->
                                  </td>
                                </tr>
                              </table>
                            </td>
                          </tr>
                        </table>
                  </table>
            </table>
          </td>
        </tr>
        
      </TABLE>
    </TD>
  </TR></TBODY></TABLE>
  <!--#include file="bottom.aspx"-->
</BODY></HTML>
